<template>
  <div>
    <!--    头部-->
    <div style="display: flex; height: 60px; line-height: 60px; border-bottom: 1px solid #eee">
      <div style="width: 300px; display: flex; padding-left: 30px">
        <div style="width: 60px">
          <img src="../../assets/logo.png" alt="" style="width: 50px; position: relative; top: 5px; right: 0">
        </div>
        <div style="flex: 1">疫情防控</div>
      </div>
      <div style="flex: 1">
        <el-menu :default-active="'1'" class="el-menu-demo" mode="horizontal" router>
          <el-menu-item index="/front/home">首页</el-menu-item>
          <el-menu-item index="/front/notice" disabled>公告列表</el-menu-item>
          <el-menu-item index="/front/noticeDetail" disabled>公告详情</el-menu-item>
          <el-menu-item index="/front/report" disabled>个人每日上报</el-menu-item>
          <el-menu-item index="/front/reportTo" disabled>出入登记</el-menu-item>
          <el-menu-item index="/front/goods">防疫物资</el-menu-item>
          <el-menu-item index="/front/cart">购物车</el-menu-item>
          <el-menu-item index="/front/order">订单管理</el-menu-item>
        </el-menu>
      </div>
      <div style="width: 200px">
        <div v-if="!user.userName" style="text-align: right; padding-right: 30px">
          <el-button @click="$router.push('/login')">登录</el-button>
          <el-button @click="$router.push('/register')">注册</el-button>
        </div>
        <div v-else>
          <el-dropdown style="width: 150px; cursor: pointer; text-align: right">
            <div style="display: inline-block;font-size: 14px">
              <el-avatar :size="28" :src="user.avatarUrl" style="margin-right: 10px"  @error="errorHandler">
                <img src="https://cube.elemecdn.com/e/fd/0fc7d20532fdaf769a25683617711png.png"/>
              </el-avatar>
              <span>{{ user.nickName }}</span><i class="el-icon-arrow-down" ></i>
            </div>
            <el-dropdown-menu slot="dropdown" style="width: 100px; text-align: center">
              <el-dropdown-item>
                <router-link to="/front/person">个人信息</router-link>
              </el-dropdown-item>
              <el-dropdown-item>
                <router-link to="/front/Password">修改密码</router-link>
              </el-dropdown-item>
              <el-dropdown-item>
                <span style="text-decoration: none;color: #29A8EFFF;width: 100%;height: 100%" @click="exit">退出</span>
              </el-dropdown-item>
            </el-dropdown-menu>
          </el-dropdown>
        </div>
      </div>
    </div>
    <div style="width:1000px;margin: 0 auto">
      <router-view />
    </div>
  </div>
</template>

<script>
export default {
  name: "Front",
  data() {
    return {
      user: localStorage.getItem("user") ? JSON.parse(localStorage.getItem("user")) : {}
    }
  },
  created() {

  },
  methods: {
    exit(){
      this.$store.commit("resetSys")
      this.$message.success("退出成功")
    },
    errorHandler() {
      return true
    }
  }
}
</script>

<style>
.item{
  display: inline-block;
  width: 100px;

  text-align: center;
  cursor: pointer
}
.item a {
  color: 	#1E90FF;
}
.router-link-active {
  text-decoration: none;
  color: #494545;
}
a{
  text-decoration: none;
  color: #29A8EFFF;
}
.item:hover{
  background-color: 	LightPink;
}
</style>
